package com.etc.myblog.biz;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.etc.myblog.dao.ArticleCatDao;
import com.etc.myblog.entity.Article;
import com.etc.myblog.entity.ArticleCat;
import com.etc.myblog.util.SessionFactoryUtil;

public class ArticleCatBiz {

	
	public List<ArticleCat> findAll() {
		List<ArticleCat> list = new ArrayList<>();
		SqlSession session = SessionFactoryUtil.getSession();
		try {
			ArticleCatDao dao = session.getMapper(ArticleCatDao.class);
			list = dao.findAll();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			session.close();
		}
		return list;
	}
	
	public ArticleCat findById(int id) {
		ArticleCat articlecat = new ArticleCat();
		SqlSession session = SessionFactoryUtil.getSession();
		try {
			ArticleCatDao dao = session.getMapper(ArticleCatDao.class);
			articlecat = dao.findById(id);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			session.close();
		}
		return articlecat;
	}
}
